﻿using System;
using static System.Threading.Thread;
using static System.Console;

namespace KongMing.Common
{
    public class UnitBase
    {
        public static void WriteCurrentTaskInfo(string taskName)
        {
            WriteLine($"{taskName} 的 id： {CurrentThread.ManagedThreadId}," +
                      $"是否是后台线程：{CurrentThread.IsBackground}," +
                      $"是否是线程池托管：{CurrentThread.IsThreadPoolThread}。");
        }

        public static string GetCurrentTaskInfo(string taskName)
        {
            return $"{taskName} 的 id： {CurrentThread.ManagedThreadId}," +
                   $"是否是后台线程：{CurrentThread.IsBackground}," +
                   $"是否是线程池托管：{CurrentThread.IsThreadPoolThread}。";
        }

        /// <summary>
        /// 将当前线程挂起多少秒
        /// </summary>
        /// <param name="seconds"></param>
        public static void SleepSeconds(int seconds)
        {
            Sleep(TimeSpan.FromSeconds(seconds));
        }
    }
}
